package com.wing.cabinet.model.entity;

import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * 刀具产品货道库存
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("cab_storage_inventory_knife")
public class StorageInventoryKnife extends BaseEntity<StorageInventoryKnife> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum BusinessType implements IEnum<Integer> {

        /**
        * 暂存
        */
        temp(1,"暂存"),
        /**
        * 维修
        */
        repair(2,"维修"),
        /**
        * 回收
        */
        recycle(3,"回收"),
        /**
         * 格子柜上货
         */
        exhibit(4,"格子柜上货"),

        outByCabSpace(5,"领取(存刀柜)");

        private int code;
        private String desc;

        BusinessType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static BusinessType jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (BusinessType item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    public enum LoadingType implements IEnum<Integer> {

        /**
         * 暂存
         */
        temp(0,"暂存"),
        /**
         * 格子柜
         */
        grid(1,"格子柜");

        private int code;
        private String desc;

        LoadingType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static LoadingType jsonCreator(String name) {
            if (com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(name)) {
                for (LoadingType item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }


    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 柜子id
     */
    private Long cabId;

    /**
     * 柜子编号
     */
    private String cabCode;

    /**
     * 货道id
     */
    private Long spaceId;

    /**
     * 货道编号
     */
    private String spaceCode;

    /**
     * sku id
     */
    private Long skuId;

    /**
     * sku 编号
     */
    private String skuCode;

    /**
     * 库存数量
     */
    private Integer quantity;

    /**
     * 业务类型
     */
    private BusinessType businessType;

    /**
    * 业务类型描述
    */
    @TableField(exist = false)
    private String businessTypeDesc;

    public String getBusinessTypeDesc() {
        return businessType == null ? null : businessType.getDesc();
    }

    /**
     * 是否已同步：no(0,未同步);yes(1,已同步);
     */
    private Integer isSyns;

    /**
    * 同步时间
    */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime synsTime;

    /**
     * deviceCode
     */
    private String deviceCode;

    /**
     * companyId
     */
    private Long companyId;

    /**
     * 存取刀id
     */
    private Long storageInventoryInoutId;

    /**
     * labelCode
     */
    private String labelCode;

    private Long storageInventoryUserId;

    private Long workOrderId;

    /**
     * 企业编码
     */
    private String enterpriseCode;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    protected LocalDateTime inTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    protected LocalDateTime outTime;

    private Integer remainingTime;


    /**
     * 寿命单位  1：小时/ 2：次数
     */
    private LifeUnit lifeUnit;

    private BusinessDetailType businessDetailType;
    /**
     * 1：分钟/ 2：个数
     */
    public enum LifeUnit implements IEnum<Integer> {

        /**
         * 分钟
         */
        minute(1,"分钟"),
        /**
         * 个数
         */
        number(2,"个数");

        private int code;
        private String desc;

        LifeUnit(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
        @JsonCreator
        public static LifeUnit jsonCreator(String name) {
            if (org.apache.commons.lang.StringUtils.isNotBlank(name)) {
                for (LifeUnit item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    public enum BusinessDetailType implements IEnum<Integer> {

        /**
         * 业务类型:cellCabReceive(1,售刀柜领取);repairOrderSign(2,维修订单签收)
         */
        cellCabOut(1,"售刀柜领新"),

        tempIn(2,"存入暂存柜"),
        /**
         * 领取
         */
        repairOrderSign(3,"维修订单签收"),

        tempOut(4,"暂存柜取出"),

        outByReturned(5,"归还仓库管理员"),

        cellCabOutByOldNew(6,"售刀柜领新(以旧换新)"),

        /**
         * 维修
         */
        repairIn(7,"维修存入"),
        /**
         * 回收
         */
        recycleIn(8,"报废存入"),


        repairOutByCheck(9,"盘验维修取出"),

        recycleOutByCheck(10,"盘验报废取出"),

        recycleInByOldNew(11,"以旧换新存入报废"),

        tempInByCheck(12,"盘验暂存存入"),

        tempOutByCheck(13,"盘验暂存取出"),

        tempOutByCheckLose(14,"盘验暂存缺失"),

        repairOutByCheckLose(15,"盘验维修缺失"),

        recycleOutByCheckLose(16,"盘验报废缺失"),

        tempInByOldNew(17,"以旧换新存入暂存"),

        repairInByOldNew(18,"以旧换新存入维修"),

        tempOutByCheckSpec(19,"盘验暂存产品规格不相符"),

        repairOutByCheckSpec(20,"盘验维修产品规格不相符"),

        recycleOutByCheckSpec(21,"盘验报废产品规格不相符"),

        importUseByExcel(22,"导入在用刀具"),

//        latticeCabinetBatchUp(30,"格子柜上货");

        newOut(24,"存刀柜新刀取出"),

        loss(31,"报失"),

        exhibit(32,"格子柜上货"),

        unload(33,"格子柜下货");


        private int code;
        private String desc;

        BusinessDetailType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static BusinessDetailType jsonCreator(String name) {
            if (com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(name)) {
                for (BusinessDetailType item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }

    }
    @TableField(exist = false)
    private String businessDetailTypeDesc;

    public String getBusinessDetailTypeDesc(){
        if (this.businessDetailType!=null){
            return this.businessDetailType.getDesc();
        }
        return "";
    }

    private Integer settingTime;

    private String knifeRemark;

    private LoadingType loadingType;

    private Long categoryId;
    /**
     * 渠道编号
     */
    private String channelCode;


    private Long processId;

    private Long departmentId;

    private Long roleId;

    private String departmentName;

    private String roleName;


    private BigDecimal price;

    private String parentLabelCode;

    private String mainCabCode;

}
